#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

bool su[100086] = { false };

int main(int argc, char const *argv[])
{
    bool flag;
    int n, arr[128], i, j, nmax;

    cin >> n;
    nmax = 0;
    for (i = 0; i < n; i++)
    {
        cin >> arr[i];
        nmax = max(arr[i], nmax);
    }

    su[0] = true;
    su[1] = true;
    for (i = 2; i <= sqrt(nmax); i++)
    {
        if (su[i])
        {
            continue;
        }
        for (j = i * 2; j <= nmax; j += i)
        {
            su[j] = true;
        }
    }

    flag = false;
    for (i = 0; i < n; i++)
    {
        if (!su[arr[i]])
        {
            if (flag)
            {
                cout << " ";
            }
            flag = true;
            cout << arr[i];
        }
    }
    
    return 0;
}
